package com.uchedao.vehicledetection.view.baseinfo;

import android.content.ContentValues;
import android.content.Context;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nostra13.universalimageloader.utils.L;
import com.uchedao.vehicledetection.R;
import com.uchedao.vehicledetection.db.DbHelper;
import com.uchedao.vehicledetection.global.GlobalInfo;
import com.uchedao.vehicledetection.inf.ICheckValueListener;
import com.uchedao.vehicledetection.loadstate.UCheDaoRelativeLayout;
import com.uchedao.vehicledetection.model.BaseInfo;
import com.uchedao.vehicledetection.model.Draft;
import com.uchedao.vehicledetection.model.OwnerInfo;
import com.uchedao.vehicledetection.model.ProcessInfo;
import com.uchedao.vehicledetection.model.TransferInfo;
import com.uchedao.vehicledetection.utils.CheckTextDateBtnValue;
import com.uchedao.vehicledetection.utils.CheckValueUtil;

/**
 * Description:基本信息——手续信息
 * Date: 2015-09-18  14:14
 * User: wushan
 */
public class BaseInfoFormalityView extends UCheDaoRelativeLayout {


    private BaseInfo baseInfo;

    private EditText savePrice;
    private TextView savePrice_start;

    private String now_price = "";

    public BaseInfoFormalityView(Context context) {
        super(context);
    }

    public BaseInfoFormalityView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BaseInfoFormalityView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean save() {
        ContentValues values = new ContentValues();
        // values.put(DbHelper.KEY_BASE_INFO, baseInfo.toString());
        values.put(DbHelper.KEY_DRAFT_BASE_INFO, toJson(baseInfo));
        int status = baseInfo.getStatus();
        values.put(DbHelper.KEY_DRAFT_BASE_INFO_STATUS, status);

        //
        if (GlobalInfo.dbHelper.updateDraf(GlobalInfo.draft.car_plate, values)) {
            GlobalInfo.draft.base_info = baseInfo.clone();
            GlobalInfo.draft.status[Draft.TYPE_BASE_INFO] = status;
            return true;
        }
        return false;
    }

    @Override
    public boolean dataChanged() {
        return !baseInfo.equals(GlobalInfo.draft.base_info);
//        return false;
    }

    @Override
    public void initDataBeforView() {
//        if (GlobalInfo.draft == null) {
//            GlobalInfo.draft = new Draft();
//        }
        baseInfo = GlobalInfo.draft.base_info.clone();
    }

    @Override
    public void initView() {

        final ProcessInfo processInfo = baseInfo.process_info;
        final OwnerInfo ownerInfo = baseInfo.owner_info;
        final TransferInfo transferInfo = baseInfo.transfer_info;

        L.i(toJson(processInfo));

        LayoutInflater.from(mContext).inflate(R.layout.view_base_formality, this);
        TextView subjectTv = (TextView) findViewById(
                R.id.base_formality_title).findViewById(R.id.subject_tv);
        // 项目标题
        subjectTv.setText(R.string.base_formality);

        //保留价
        savePrice = (EditText) findViewById(R.id.base_car_price_et);
        savePrice_start = (TextView) findViewById(R.id.base_car_price_tv);
        savePrice.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence s, int start, int before,
                                      int count) {
                if (s.toString().contains(".")) {
                    if (s.toString().indexOf(".") > 3) {
                        setContent(now_price, now_price.length());
                        return;
                    }
                    if (s.length() - 1 - s.toString().indexOf(".") > 2) {
                        s = s.toString().subSequence(0,
                                s.toString().indexOf(".") + 3);
                        setContent(s.toString(), s.length());
//                        savePrice.setText(s);
//                        savePrice.setSelection(s.length());
                    }
                } else {
                    if (s.length() > 3) {
                        s = s.toString().substring(0, 3);
                        setContent(s.toString(), s.length());
//                        savePrice.setText(s);
//                        savePrice.setSelection(s.length());
                    }
                }
                if (s.toString().trim().substring(0).equals(".")) {
                    s = "0" + s;
                    setContent(s.toString(), 2);
//                    savePrice.setText(s);
//                    savePrice.setSelection(2);
                }

                if (s.toString().startsWith("0")
                        && s.toString().trim().length() > 1) {
                    if (!s.toString().substring(1, 2).equals(".")) {
                        setContent(s.subSequence(0, 1).toString(), 1);
//                        savePrice.setText(s.subSequence(0, 1));
//                        savePrice.setSelection(1);
                        return;
                    }
                }
            }

            void setContent(String price, int position) {
                now_price = price;
                savePrice.setText(price);
                savePrice.setSelection(position);
            }

            @Override
            public void beforeTextChanged(CharSequence s, int start, int count,
                                          int after) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                if (savePrice_start != null) {// 有textview时，设置星号是否显示
                    setStar(savePrice_start, TextUtils.isEmpty(s));
                }
                processInfo.save_price = TextUtils.isEmpty(s) ? "" : s.toString();
            }

            /**
             * 设置是否显示星号
             *
             * @param tv
             * @param show
             */
            void setStar(TextView tv, boolean show) {
                // tv.setCompoundDrawables(show ? DRAWABLE_STAR : DRAWABLE_STAR_NO,
                // null,
                // null, null);
                tv.setCompoundDrawablesWithIntrinsicBounds(show ? R.mipmap.read_star : R.mipmap.read_star_no, 0, 0, 0);
            }

        });
        savePrice.setText(TextUtils.isEmpty(processInfo.save_price) ? ""
                : processInfo.save_price);
//        CheckValueUtil.textEditListener(this, R.id.base_car_price_tv, R.id.base_car_price_et, TextUtils
//                .isEmpty(processInfo.save_price) ? ""
//                : processInfo.save_price, new ICheckValueListener() {
//            @Override
//            public void getValue(View v, String str) {
//                processInfo.save_price = str;
//            }
//        });

        // 购车发票
        CheckValueUtil.textBtnListener(this,
                R.id.base_buy_invoice_tv, R.id.base_buy_invoice_bt,
                R.array.buy_invoice_strValue, processInfo.invoice,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.invoice = str;
                    }
                });

        // 行驶证
        CheckValueUtil.textBtnListener(this,
                R.id.base_driving_license_tv, R.id.base_driving_license_bt,
                R.array.third_chooice_strValue, processInfo.driving_license,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.driving_license = str;
                    }
                });

        // 登记证
        CheckValueUtil.textBtnListener(this,
                R.id.base_registe_license_tv, R.id.base_registe_license_bt,
                R.array.third_chooice_strValue, processInfo.driving_license,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.registration = str;
                    }
                });

        // 购置税证
        CheckValueUtil.textBtnListener(this,
                R.id.base_buy_license_tv, R.id.base_buy_license_bt,
                R.array.buy_tax_strValues, processInfo.surtax_card,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.surtax_card = str;
                    }
                });

        // 车船税
        CheckValueUtil.textBtnListener(this,
                R.id.base_vechile_tax_tv, R.id.base_vechile_tax_bt,
                R.array.third_chooice_strValue, processInfo.travel_tax,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.travel_tax = str;

                        Button base_vechile_tax_time_bt = (Button) findViewById(R.id.base_vechile_tax_time_bt);
                        // L.w("车船税 "+str);
                        if (str.equals("有")) {
                            base_vechile_tax_time_bt
                                    .setVisibility(View.VISIBLE);
                            base_vechile_tax_time_bt.setText("");

                            // 当有时，设置车船税日期的监听
                            CheckValueUtil.textDateBtnListener(
                                    CheckTextDateBtnValue.TYPE_YEAR,
                                    BaseInfoFormalityView.this, R.id.base_vechile_tax_tv,
                                    R.id.base_vechile_tax_time_bt,
                                    processInfo.travel_tax_time,
                                    new ICheckValueListener() {

                                        @Override
                                        public void getValue(View v, String str) {
                                            processInfo.travel_tax_time = str;
                                        }
                                    });
                        } else {// 无或未见时，控件不可见，值设置为空。
                            base_vechile_tax_time_bt.setVisibility(View.GONE);
                            processInfo.travel_tax_time = "";
                        }
                    }
                });

        // 车船税日期
        Button base_vechile_tax_time_bt = (Button) this
                .findViewById(R.id.base_vechile_tax_time_bt);
        // base_vechile_tax_time_bt.setVisibility(View.GONE);
        base_vechile_tax_time_bt.setHint(R.string.base_vehicle_time_tips);

        // 年检
        CheckValueUtil.textBtnListener(this,
                R.id.base_annual_survey_tv, R.id.base_annual_survey_bt,
                R.array.annual_survey_strValues, processInfo.year_check,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.year_check = str;

                        Button base_annual_survey_time_bt = (Button) findViewById(R.id.base_annual_survey_time_bt);
                        if (str.equals("有效")) {
                            base_annual_survey_time_bt
                                    .setVisibility(View.VISIBLE);
                            base_annual_survey_time_bt.setText("");

                            // 当选有效时，出现监听年检有效期
                            CheckValueUtil.textDateBtnListener(
                                    CheckTextDateBtnValue.TYPE_YEAR_MONTH_DAY,
                                    BaseInfoFormalityView.this,
                                    R.id.base_annual_survey_tv,
                                    R.id.base_annual_survey_time_bt,
                                    processInfo == null ? ""
                                            : processInfo.year_check_time,
                                    new ICheckValueListener() {

                                        @Override
                                        public void getValue(View v, String str) {
                                            processInfo.year_check_time = str;
                                        }
                                    });
                        } else {// 无效时，控件不可见，值设置为空。
                            base_annual_survey_time_bt.setVisibility(View.GONE);
                            processInfo.year_check_time = "";
                        }
                    }
                });
        // 年检有效期
        Button base_annual_survey_time_bt = (Button) this
                .findViewById(R.id.base_annual_survey_time_bt);
        // base_annual_survey_time_bt.setVisibility(View.GONE);
        base_annual_survey_time_bt.setHint(R.string.base_dateline_tips);

        // 交强险
        CheckValueUtil.textBtnListener(this,
                R.id.base_compulsory_insurance_tv,
                R.id.base_compulsory_insurance_bt,
                R.array.third_chooice_strValue, processInfo == null ? ""
                        : processInfo.safe_force, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.safe_force = str;

                        Button base_compulsory_insurance_time_bt = (Button) findViewById(R.id.base_compulsory_insurance_time_bt);
                        if (str.equals("有")) {
                            base_compulsory_insurance_time_bt
                                    .setVisibility(View.VISIBLE);
                            base_compulsory_insurance_time_bt.setText("");

                            // 当有交强险时，出现
                            CheckValueUtil.textDateBtnListener(
                                    CheckTextDateBtnValue.TYPE_YEAR_MONTH_DAY,
                                    BaseInfoFormalityView.this,
                                    R.id.base_compulsory_insurance_tv,
                                    R.id.base_compulsory_insurance_time_bt,
                                    processInfo == null ? ""
                                            : processInfo.safe_force_time,
                                    new ICheckValueListener() {

                                        @Override
                                        public void getValue(View v, String str) {
                                            processInfo.safe_force_time = str;
                                        }
                                    });
                        } else {// 无或未见时，控件不可见，值设置为空。
                            base_compulsory_insurance_time_bt
                                    .setVisibility(View.GONE);
                            processInfo.safe_force_time = "";
                        }
                    }
                });

        // 交强险有效期
        Button base_compulsory_insurance_time_bt = (Button) this
                .findViewById(R.id.base_compulsory_insurance_time_bt);
        // base_compulsory_insurance_time_bt.setVisibility(View.GONE);
        base_compulsory_insurance_time_bt.setHint(R.string.base_dateline_tips);

        // 商业保险
        CheckValueUtil.textBtnListener(this,
                R.id.base_commercial_insurance_tv,
                R.id.base_commercial_insurance_bt, R.array.have_entries,
                processInfo == null ? "" : processInfo.safe_business,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.safe_business = str;

                        Button base_commercial_insurance_sale_bt = (Button) findViewById(R.id.base_commercial_insurance_sale_bt);
                        TextView base_commercial_insurance_sale_tv = (TextView) findViewById(R.id.base_commercial_insurance_sale_tv);
                        LinearLayout layout_base_commercial_insurance = (LinearLayout) findViewById(R.id.base_commercial_insurance_sale_layout);
                        if (str.equals("有")) {
                            // 随车出售可见
                            layout_base_commercial_insurance.setVisibility(View.VISIBLE);
                            base_commercial_insurance_sale_tv
                                    .setVisibility(View.VISIBLE);
                            base_commercial_insurance_sale_bt
                                    .setVisibility(View.VISIBLE);

                        } else {// 无效时，随车出售控件不可见
                            layout_base_commercial_insurance.setVisibility(View.GONE);
                            base_commercial_insurance_sale_tv
                                    .setVisibility(View.GONE);
                            base_commercial_insurance_sale_bt
                                    .setVisibility(View.GONE);
                            // 随车出售值设置为空
                            processInfo.safe_business_sale = null;
                            processInfo.safe_business_amount = null;
                            processInfo.safe_business_time = null;
                            processInfo.insurance_company = null;
                            processInfo.insurance_company_other = null;
                        }

                        base_commercial_insurance_sale_bt.setText("");

                        // 商业险金额有效期不可见
                        findViewById(
                                R.id.base_commercial_insurance_msg_layout)
                                .setVisibility(View.GONE);
                        // 保险公司不可见
                        findViewById(
                                R.id.base_commercial_insurance_com_layout)
                                .setVisibility(View.GONE);

                        // 商业险金额
                        EditText base_commercial_insurance_money_et = (EditText) findViewById(R.id.base_commercial_insurance_money_et);

                        // 商业险有效期
                        Button base_commercial_insurance_time_bt = (Button) findViewById(R.id.base_commercial_insurance_time_bt);

                        // 保险公司
                        Button base_insurance_company_bt = (Button) findViewById(R.id.base_insurance_company_bt);

                        // 自填保险公司
                        EditText base_insurance_company_et = (EditText) findViewById(R.id.base_insurance_company_et);
                        base_commercial_insurance_money_et.setText("");
                        base_commercial_insurance_time_bt.setText("");
                        base_insurance_company_bt.setText("");
                        base_insurance_company_et.setText("");
                    }
                });

        // 随车出售
        // TextView base_commercial_insurance_sale_tv = (TextView)
        // this
        // .findViewById(R.id.base_commercial_insurance_sale_tv);
        // base_commercial_insurance_sale_tv.setVisibility(View.GONE);
        // Button base_commercial_insurance_sale_bt = (Button) this
        // .findViewById(R.id.base_commercial_insurance_sale_bt);
        // base_commercial_insurance_sale_bt.setVisibility(View.GONE);

        // LinearLayout base_commercial_insurance_msg_layout = (LinearLayout)
        // this
        // .findViewById(R.id.base_commercial_insurance_msg_layout);
        // base_commercial_insurance_msg_layout.setVisibility(View.GONE);

        CheckValueUtil.textBtnListener(this,
                R.id.base_commercial_insurance_sale_tv,
                R.id.base_commercial_insurance_sale_bt,
                R.array.boolean_entries, processInfo == null ? ""
                        : processInfo.safe_business_sale,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.safe_business_sale = str;
                        LinearLayout base_commercial_insurance_msg_layout = (LinearLayout) findViewById(R.id.base_commercial_insurance_msg_layout);
                        LinearLayout base_commercial_insurance_com_layout = (LinearLayout) findViewById(R.id.base_commercial_insurance_com_layout);
                        EditText base_commercial_insurance_money_et = (EditText) findViewById(R.id.base_commercial_insurance_money_et);
                        Button base_commercial_insurance_time_bt = (Button) findViewById(R.id.base_commercial_insurance_time_bt);
                        Button base_insurance_company_bt = (Button) findViewById(R.id.base_insurance_company_bt);
                        EditText base_insurance_company_et = (EditText) findViewById(R.id.base_insurance_company_et);
                        if (str.equals("是")) {
                            base_commercial_insurance_msg_layout
                                    .setVisibility(View.VISIBLE);
                            base_commercial_insurance_com_layout
                                    .setVisibility(View.VISIBLE);

                        } else {// 不随车出售时，控件不可见，值设置为空。
                            base_commercial_insurance_msg_layout
                                    .setVisibility(View.GONE);
                            base_commercial_insurance_com_layout
                                    .setVisibility(View.GONE);

                            processInfo.safe_business_amount = null;
                            processInfo.safe_business_time = null;
                            processInfo.insurance_company = null;
                            processInfo.insurance_company_other = null;
                        }

                        base_commercial_insurance_money_et.setText("");
                        base_commercial_insurance_time_bt.setText("");
                        base_insurance_company_bt.setText("");
                        base_insurance_company_et.setText("");
                    }
                });

        // 商业险金额
        CheckValueUtil.textEditListener(this,
                R.id.base_commercial_insurance_money_tv,
                R.id.base_commercial_insurance_money_et,
                processInfo.safe_business_amount, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.safe_business_amount = str;
                    }
                });

        // 商险有效期
        Button base_commercial_insurance_time_bt = (Button) this
                .findViewById(R.id.base_commercial_insurance_time_bt);
        base_commercial_insurance_time_bt.setHint(R.string.base_dateline_tips);
        CheckValueUtil.textDateBtnListener(
                CheckTextDateBtnValue.TYPE_YEAR_MONTH_DAY, this,
                R.id.base_commercial_insurance_time_tv,
                R.id.base_commercial_insurance_time_bt,
                processInfo.safe_business_time, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.safe_business_time = str;
                    }
                });

        // 保险公司
        // LinearLayout base_commercial_insurance_com_layout = (LinearLayout)
        // this
        // .findViewById(R.id.base_commercial_insurance_com_layout);
        // base_commercial_insurance_com_layout.setVisibility(View.GONE);
        CheckValueUtil.textBtnListener(this,
                R.id.base_insurance_company_tv, R.id.base_insurance_company_bt,
                R.array.insurance_company_strValues,
                processInfo.insurance_company, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.insurance_company = str;

                        EditText base_insurance_company_et = (EditText) findViewById(R.id.base_insurance_company_et);
                        if (str.equals("自填")) {
                            base_insurance_company_et
                                    .setVisibility(View.VISIBLE);
                            base_insurance_company_et.setText("");

                            // 自填保险公司名称
                            CheckValueUtil.textEditListener(BaseInfoFormalityView.this,
                                    R.id.base_insurance_company_tv,
                                    R.id.base_insurance_company_et,
                                    processInfo.insurance_company_other,
                                    new ICheckValueListener() {

                                        @Override
                                        public void getValue(View v, String str) {
                                            processInfo.insurance_company_other = str;

                                        }
                                    });

                        } else {// 非自填时，控件不可见，值设置为空。
                            base_insurance_company_et
                                    .setVisibility(View.GONE);//invisibe
                            processInfo.insurance_company_other = null;
                        }

                    }
                });

        // 车主身份证
        CheckValueUtil.textBtnListener(this,
                R.id.base_car_owner_idcard_tv, R.id.base_car_owner_idcard_bt,
                R.array.have_entries, processInfo.owner_card,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.owner_card = str;
                    }
                });

        // 车身铭牌
        CheckValueUtil.textBtnListener(this,
                R.id.base_name_plate_tv, R.id.base_name_plate_bt,
                R.array.third_chooice_strValue, processInfo.body_nameplate,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.body_nameplate = str;
                    }
                });

        // 违章记录
        CheckValueUtil.textBtnListener(this, R.id.base_illegal_tv,
                R.id.base_illegal_bt, R.array.have_entries,
                processInfo.illegal_info, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        processInfo.illegal_info = str;

                        LinearLayout base_illegal_layout = (LinearLayout) findViewById(R.id.base_illegal_layout);
                        EditText base_illegal_fine_et = (EditText) findViewById(R.id.base_illegal_fine_et);
                        EditText base_illegal_discount_et = (EditText) findViewById(R.id.base_illegal_discount_et);
                        if (str.equals("有")) {
                            base_illegal_layout.setVisibility(View.VISIBLE);
                            base_illegal_fine_et.setText("");
                            base_illegal_discount_et.setText("");

                            // 当有违章时，出现 罚款 扣分
                            CheckValueUtil.textEditListener(BaseInfoFormalityView.this,
                                    R.id.base_illegal_tv,
                                    R.id.base_illegal_fine_et,
                                    processInfo.illegal_fine,
                                    R.id.base_illegal_discount_et,
                                    processInfo.illegal_detained_scores,
                                    new ICheckValueListener() {

                                        @Override
                                        public void getValue(View v, String str) {
                                            if (v.getId() == R.id.base_illegal_fine_et)
                                                processInfo.illegal_fine = str;
                                            else if (v.getId() == R.id.base_illegal_discount_et)
                                                processInfo.illegal_detained_scores = str;
                                        }
                                    });

                        } else {// 非自填时，控件不可见，值设置为空。
                            base_illegal_layout.setVisibility(View.GONE);//invisibe
                            processInfo.illegal_fine = null;
                            processInfo.illegal_detained_scores = null;
                        }
                    }
                });

        // LinearLayout base_illegal_layout = (LinearLayout)
        // this.findViewById(R.id.base_illegal_layout);
        // base_illegal_layout.setVisibility(View.INVISIBLE);

        // transfer 过户情况
        TextView transferSubtitle = (TextView) this.findViewById(
                R.id.base_formality_transfer_situation_subtitle).findViewById(
                R.id.subject_tv);
        transferSubtitle.setText(R.string.base_transfer_situation_title);

        // 过户次数
        CheckValueUtil.textEditListener(this,
                R.id.base_transfer_num_tv, R.id.base_transfer_num_et, TextUtils
                        .isEmpty(transferInfo.transfer_num) ? "0"
                        : transferInfo.transfer_num, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        transferInfo.transfer_num = str;
                    }
                });

        // 是否抵押
        CheckValueUtil.textBtnListener(this,
                R.id.base_transfer_mortgage_tv, R.id.base_transfer_mortgage_bt,
                R.array.boolean_entries, TextUtils
                        .isEmpty(transferInfo.transfer_mortgage) ? "否"
                        : transferInfo.transfer_mortgage,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        transferInfo.transfer_mortgage = str;
                    }
                });
        // 是否变更外观
        CheckValueUtil.textBtnListener(this,
                R.id.base_transfer_appearance_tv,
                R.id.base_transfer_appearance_bt, R.array.boolean_entries,
                TextUtils.isEmpty(transferInfo.transfer_appearance) ? "否"
                        : transferInfo.transfer_appearance,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        transferInfo.transfer_appearance = str;
                    }
                });
        // 是否变更车架号
        CheckValueUtil.textBtnListener(this,
                R.id.base_transfer_frame_number_tv,
                R.id.base_transfer_frame_number_bt, R.array.boolean_entries,
                TextUtils.isEmpty(transferInfo.transfer_frame_number) ? "否"
                        : transferInfo.transfer_frame_number,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        transferInfo.transfer_frame_number = str;
                    }
                });
        // 是否变更发动机号
        CheckValueUtil.textBtnListener(this,
                R.id.base_transfer_engine_tv, R.id.base_transfer_engine_bt,
                R.array.boolean_entries, TextUtils
                        .isEmpty(transferInfo.transfer_engine) ? "否"
                        : transferInfo.transfer_engine,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        transferInfo.transfer_engine = str;
                    }
                });
        // 是否变更其他改装件
        CheckValueUtil.textBtnListener(this,
                R.id.base_transfer_other_tv, R.id.base_transfer_other_bt,
                R.array.boolean_entries, TextUtils
                        .isEmpty(transferInfo.transfer_other) ? "否"
                        : transferInfo.transfer_other,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        transferInfo.transfer_other = str;
                    }
                });

        // Subject 买主信息
        TextView ownerSubtitle = (TextView) this.findViewById(
                R.id.base_formality_owner_and_client_subtitle).findViewById(
                R.id.subject_tv);

        // 项目标题
        ownerSubtitle.setText(R.string.base_owner_and_client_title);

        // 买主名字
        CheckValueUtil.editListener(this, R.id.base_owner_name_et,
                ownerInfo.owner_name, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        ownerInfo.owner_name = str;
                    }
                });

        // 买主身份证
        CheckValueUtil.editListener(this,
                R.id.base_owner_id_card_et, ownerInfo.cert_number,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        ownerInfo.cert_number = str;
                    }
                });

        // 买主电话
        CheckValueUtil.editListener(this, R.id.base_owner_phone_et,
                ownerInfo.owner_contact, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        ownerInfo.owner_contact = str;
                    }
                });

        // 委托人
        CheckValueUtil.editListener(this, R.id.base_client_name_et,
                ownerInfo.trustor_name, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        ownerInfo.trustor_name = str;
                    }
                });

        // 委托人身份证
        CheckValueUtil.editListener(this,
                R.id.base_client_id_card_et, ownerInfo.trustor_cert_number,
                new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        ownerInfo.trustor_cert_number = str;
                    }
                });

        // 委托人电话
        CheckValueUtil.editListener(this, R.id.base_client_phone_et,
                ownerInfo.trustor_contact, new ICheckValueListener() {

                    @Override
                    public void getValue(View v, String str) {
                        ownerInfo.trustor_contact = str;
                    }
                });
    }

    @Override
    public void initDataAfterView() {

    }

    @Override
    public void initListener() {

    }
}
